package org.example.model.common;

import lombok.Data;

/**
 * @Author: Ran
 * @Date: 2021/9/15
 **/
@Data
public class Response<T> {

    private String errCode;

    private String errMessage;

    private Boolean success;

    private T data;

    public static Response buildFailure(String errCode, String errMessage) {
        Response response = new Response();
        response.setSuccess(false);
        response.setErrCode(errCode);
        response.setErrMessage(errMessage);
        return response;
    }

    public static <T> Response<T> buildSuccess(T data) {
        Response response = new Response();
        response.setData(data);
        response.setSuccess(true);
        return response;
    }
}
